package com.maychat.pojo.extended;

import com.maychat.pojo.ChatMessage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serial;
import java.io.Serializable;

@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Message<T> extends ChatMessage implements Serializable {

    @Serial
    private static final long serialVersionUID = -2119331941797642507L;

    private String contactName;
    private String lastMessage;

    private T extendedData;

    private Integer memberCount;

    public String getLastMessage() {
        if (StringUtils.isBlank(this.lastMessage))
            return this.messageContent;
        return this.lastMessage;
    }
}
